package org.auth.framework;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public interface CustomUserDetailsService extends UserDetailsService {
	
	/**
	 * 取得用户情报
	 * 
	 * @param username 用户名
	 * @param authentication 授权信息
	 * @return 用户情况
	 * 
	 * @throws UsernameNotFoundException 用户未找到
	 */
	public UserDetails loadUserByUsername(String username, UsernamePasswordAuthenticationToken authentication) throws UsernameNotFoundException;
	
	/**
	 * 是否授权
	 * 
	 * @param userDetails 用户信息
	 * @param authentication 授权信息
	 * @return 授权状态
	 */
	public boolean isAuthentication(UserDetails userDetails,
			UsernamePasswordAuthenticationToken authentication);
	
	/**
	 * 认证后处理
	 * 
	 * @param principal 认证
	 * @param authentication 授权信息
	 * @param user 用户
	 */
	public void postExecute(Object principal,
			Authentication authentication, UserDetails user);
}
